package com.wicket.okroperation.run;

import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSONObject;
//import com.douliwan.DouliwanHeader;
import com.wicket.okroperation.common.util.CommonFunctionHelper;
import com.wicket.okroperation.common.util.RedisUtil;
import org.mybatis.spring.annotation.MapperScan;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
 * @author ：CHS
 * @since 2022/1/13 16:53
 *
 *
 * @version 1.0
 */
@SpringBootApplication(scanBasePackages = {"com.wicket.okroperation", "com.wicket.okroperation.common.mq.config", "com.wicket.okroperation"})
@MapperScan("com.wicket.okroperation.dal.mapper.mbg")
@ComponentScan(basePackages = {"com.wicket.okroperation"})
@EnableTransactionManagement
@EnableFeignClients(basePackages = {"com.wicket.okrcomponent.integration", "com.wicket.okroperation", "com.wicket.okrframework.integration","com.wicket.okrcalc.integration","com.wicket.okrapp.integration"})
public class ApplicationRunner extends SpringBootServletInitializer implements CommandLineRunner {

    @Value("${security.db.address}")
    private String dbAddress;

    @Value("${security.db.account}")
    private String dbAccount;

    @Value("${security.db.password}")
    private String dbPassword;

    @Value("${file.path}")
    private String filePath;

    @Resource
    private RedisUtil redisUtil;

//    private static DouliwanHeader douliwan = new DouliwanHeader();
    private static final Logger log = LoggerFactory.getLogger(ApplicationRunner.class);

    public static void main(String[] args) {

        SpringApplication.run(ApplicationRunner.class, args);


    }

    @Override
    public void run(String... args) throws Exception {
        log.info("app start");
        //get();
        String useFlag = System.getProperty("use.douliwan");
        String str = "\"{\\\"branchName\\\":\\\"license_20240630232937\\\",\\\"info\\\":{\\\"BASIC_EDU_DEPT_PLAN_MGT\\\":{\\\"applObjType\\\":\\\"EVA_THEME\\\",\\\"applexName\\\":\\\"双基建设管理（评价主题）\\\",\\\"authorizationId\\\":\\\"2241875641510297603\\\",\\\"authorizationKeyTypeCode\\\":\\\"BASIC_EDU_DEPT_PLAN_MGT\\\",\\\"authorizationName\\\":\\\"双基建设管理（评价主题）\\\",\\\"authorizationNum\\\":\\\"1\\\",\\\"authorizationObjectId\\\":\\\"159677195001012224\\\",\\\"authorizationSchemeId\\\":\\\"215428055324569600\\\",\\\"authorizationSpaceId\\\":\\\"81705860010741760\\\",\\\"authorizationUnit\\\":\\\"COVER\\\",\\\"deployTypeCode\\\":\\\"SAAS\\\",\\\"isDeploymentEnabled\\\":\\\"TRUE\\\",\\\"isMainAuthorization\\\":\\\"TRUE\\\",\\\"operateTime\\\":1684999280000,\\\"operationInductionId\\\":\\\"127121849724444672\\\",\\\"pageNum\\\":0,\\\"pageSize\\\":0,\\\"schOpenRecordCode\\\":\\\"217765675132137473\\\",\\\"schOpenRecordId\\\":\\\"220679731149156352\\\",\\\"schemeAuthorizationType\\\":\\\"QUANTITY\\\",\\\"subjectLifeCycle\\\":\\\"CURRENTLY_VALID\\\",\\\"totalNum\\\":0},\\\"RAISE_EXCELLENT_QUALITY\\\":{\\\"applObjType\\\":\\\"EVA_THEME\\\",\\\"applexName\\\":\\\"提质培优（评价主题）\\\",\\\"authorizationId\\\":\\\"2241875641510297601\\\",\\\"authorizationKeyTypeCode\\\":\\\"RAISE_EXCELLENT_QUALITY\\\",\\\"authorizationName\\\":\\\"提质培优（评价主题）\\\",\\\"authorizationNum\\\":\\\"1\\\",\\\"authorizationObjectId\\\":\\\"223564805884624896\\\",\\\"authorizationSchemeId\\\":\\\"141267949670772736\\\",\\\"authorizationSpaceId\\\":\\\"81705860010741760\\\",\\\"authorizationUnit\\\":\\\"COVER\\\",\\\"deployTypeCode\\\":\\\"SAAS\\\",\\\"isDeploymentEnabled\\\":\\\"TRUE\\\",\\\"isMainAuthorization\\\":\\\"TRUE\\\",\\\"operateTime\\\":1684999280000,\\\"operationInductionId\\\":\\\"127121849724444672\\\",\\\"pageNum\\\":0,\\\"pageSize\\\":0,\\\"schOpenRecordCode\\\":\\\"217765675132137473\\\",\\\"schOpenRecordId\\\":\\\"223564806165508096\\\",\\\"schemeAuthorizationType\\\":\\\"QUANTITY\\\",\\\"subjectLifeCycle\\\":\\\"CURRENTLY_VALID\\\",\\\"totalNum\\\":0},\\\"FOURTEEN_FIVE_PLAN\\\":{\\\"applObjType\\\":\\\"EVA_THEME\\\",\\\"applexName\\\":\\\"十四五规划（评价主题）\\\",\\\"authorizationId\\\":\\\"2241875641510297606\\\",\\\"authorizationKeyTypeCode\\\":\\\"FOURTEEN_FIVE_PLAN\\\",\\\"authorizationName\\\":\\\"十四五规划（评价主题）\\\",\\\"authorizationNum\\\":\\\"1\\\",\\\"authorizationObjectId\\\":\\\"217765674712842240\\\",\\\"authorizationSchemeId\\\":\\\"215428055324569600\\\",\\\"authorizationSpaceId\\\":\\\"81705860010741760\\\",\\\"authorizationUnit\\\":\\\"COVER\\\",\\\"deployTypeCode\\\":\\\"SAAS\\\",\\\"isDeploymentEnabled\\\":\\\"TRUE\\\",\\\"isMainAuthorization\\\":\\\"TRUE\\\",\\\"operateTime\\\":1684999280000,\\\"operationInductionId\\\":\\\"127121849724444672\\\",\\\"pageNum\\\":0,\\\"pageSize\\\":0,\\\"schOpenRecordCode\\\":\\\"217765675132137473\\\",\\\"schOpenRecordId\\\":\\\"217765675132137472\\\",\\\"schemeAuthorizationType\\\":\\\"QUANTITY\\\",\\\"subjectLifeCycle\\\":\\\"CURRENTLY_VALID\\\",\\\"totalNum\\\":0},\\\"ANNUAL_WORK\\\":{\\\"applObjType\\\":\\\"EVA_THEME\\\",\\\"applexName\\\":\\\"年工作规划（评价主题）-新数质\\\",\\\"authorizationId\\\":\\\"224187564151029760\\\",\\\"authorizationKeyTypeCode\\\":\\\"ANNUAL_WORK\\\",\\\"authorizationName\\\":\\\"年工作规划（评价主题）-新数质\\\",\\\"authorizationNum\\\":\\\"1\\\",\\\"authorizationObjectId\\\":\\\"217765674712842240\\\",\\\"authorizationSchemeId\\\":\\\"215428055324569600\\\",\\\"authorizationSpaceId\\\":\\\"81705860010741760\\\",\\\"authorizationUnit\\\":\\\"COVER\\\",\\\"deployTypeCode\\\":\\\"SAAS\\\",\\\"isDeploymentEnabled\\\":\\\"TRUE\\\",\\\"isMainAuthorization\\\":\\\"TRUE\\\",\\\"operateTime\\\":1684999280000,\\\"operationInductionId\\\":\\\"127121849724444672\\\",\\\"pageNum\\\":0,\\\"pageSize\\\":0,\\\"schOpenRecordCode\\\":\\\"217765675132137473\\\",\\\"schOpenRecordId\\\":\\\"217765675132137472\\\",\\\"schemeAuthorizationType\\\":\\\"QUANTITY\\\",\\\"subjectLifeCycle\\\":\\\"CURRENTLY_VALID\\\",\\\"totalNum\\\":0},\\\"QUALITY_ASSESS\\\":{\\\"applObjType\\\":\\\"EVA_THEME\\\",\\\"applexName\\\":\\\"高质量发展综合考核（评价主题）\\\",\\\"authorizationId\\\":\\\"2241875641510297602\\\",\\\"authorizationKeyTypeCode\\\":\\\"QUALITY_ASSESS\\\",\\\"authorizationName\\\":\\\"高质量发展综合考核（评价主题）\\\",\\\"authorizationNum\\\":\\\"1\\\",\\\"authorizationObjectId\\\":\\\"217765674712842240\\\",\\\"authorizationSchemeId\\\":\\\"215428055324569600\\\",\\\"authorizationSpaceId\\\":\\\"81705860010741760\\\",\\\"authorizationUnit\\\":\\\"COVER\\\",\\\"deployTypeCode\\\":\\\"SAAS\\\",\\\"isDeploymentEnabled\\\":\\\"TRUE\\\",\\\"isMainAuthorization\\\":\\\"TRUE\\\",\\\"operateTime\\\":1684999280000,\\\"operationInductionId\\\":\\\"127121849724444672\\\",\\\"pageNum\\\":0,\\\"pageSize\\\":0,\\\"schOpenRecordCode\\\":\\\"162628875967672321\\\",\\\"schOpenRecordId\\\":\\\"162628875967672320\\\",\\\"schemeAuthorizationType\\\":\\\"QUANTITY\\\",\\\"subjectLifeCycle\\\":\\\"CURRENTLY_VALID\\\",\\\"totalNum\\\":0},\\\"DOUBBLE_HEIGHT_MAJOR\\\":{\\\"applObjType\\\":\\\"EVA_THEME\\\",\\\"applexName\\\":\\\"双高专业群（评价主题）\\\",\\\"authorizationId\\\":\\\"2241875641510297604\\\",\\\"authorizationKeyTypeCode\\\":\\\"DOUBBLE_HEIGHT_MAJOR\\\",\\\"authorizationName\\\":\\\"双高专业群（评价主题）\\\",\\\"authorizationNum\\\":\\\"1\\\",\\\"authorizationObjectId\\\":\\\"223565251500064768\\\",\\\"authorizationSchemeId\\\":\\\"215428055324569600\\\",\\\"authorizationSpaceId\\\":\\\"81705860010741760\\\",\\\"authorizationUnit\\\":\\\"COVER\\\",\\\"deployTypeCode\\\":\\\"SAAS\\\",\\\"isDeploymentEnabled\\\":\\\"TRUE\\\",\\\"isMainAuthorization\\\":\\\"TRUE\\\",\\\"operateTime\\\":1684999280000,\\\"operationInductionId\\\":\\\"127121849724444672\\\",\\\"pageNum\\\":0,\\\"pageSize\\\":0,\\\"schOpenRecordCode\\\":\\\"217765675132137473\\\",\\\"schOpenRecordId\\\":\\\"223565251659313152\\\",\\\"schemeAuthorizationType\\\":\\\"QUANTITY\\\",\\\"subjectLifeCycle\\\":\\\"CURRENTLY_VALID\\\",\\\"totalNum\\\":0},\\\"ORG_BRANCH_WORK\\\":{\\\"applexName\\\":\\\"党组织重点工作（评价主题）\\\",\\\"authorizationId\\\":\\\"288371239725580288\\\",\\\"authorizationKeyTypeCode\\\":\\\"ORG_BRANCH_WORK\\\",\\\"authorizationName\\\":\\\"党组织重点工作（评价主题）\\\",\\\"authorizationNum\\\":\\\"1\\\",\\\"authorizationObjectId\\\":\\\"288371192153784320\\\",\\\"authorizationSchemeId\\\":\\\"287915068027711488\\\",\\\"authorizationSpaceId\\\":\\\"81705860010741760\\\",\\\"authorizationUnit\\\":\\\"COVER\\\",\\\"deployTypeCode\\\":\\\"SAAS\\\",\\\"isDeploymentEnabled\\\":\\\"TRUE\\\",\\\"isMainAuthorization\\\":\\\"TRUE\\\",\\\"operateTime\\\":1700301907000,\\\"operationInductionId\\\":\\\"232587494531801088\\\",\\\"pageNum\\\":0,\\\"pageSize\\\":0,\\\"schOpenRecordCode\\\":\\\"288371192199786497\\\",\\\"schOpenRecordId\\\":\\\"288371192199786496\\\",\\\"schemeAuthorizationType\\\":\\\"QUANTITY\\\",\\\"subjectLifeCycle\\\":\\\"CURRENTLY_VALID\\\",\\\"totalNum\\\":0},\\\"IRREGULAR_CYCLE_EVA_THEME\\\":{\\\"applObjType\\\":\\\"EVA_THEME\\\",\\\"applexName\\\":\\\"项目管理（评价主题）-新数质\\\",\\\"authorizationEndTime\\\":1684944000000,\\\"authorizationId\\\":\\\"224187564578848768\\\",\\\"authorizationKeyTypeCode\\\":\\\"IRREGULAR_CYCLE_EVA_THEME\\\",\\\"authorizationName\\\":\\\"项目管理（评价主题）-新数质\\\",\\\"authorizationObjectId\\\":\\\"218430187715969024\\\",\\\"authorizationSchemeId\\\":\\\"141603855057432576\\\",\\\"authorizationSpaceId\\\":\\\"81705860010741760\\\",\\\"authorizationStartTime\\\":1683561600000,\\\"deployTypeCode\\\":\\\"SAAS\\\",\\\"isDeploymentEnabled\\\":\\\"TRUE\\\",\\\"isMainAuthorization\\\":\\\"TRUE\\\",\\\"operateTime\\\":1684999281000,\\\"operationInductionId\\\":\\\"127121849724444672\\\",\\\"pageNum\\\":0,\\\"pageSize\\\":0,\\\"schOpenRecordCode\\\":\\\"218430187829080065\\\",\\\"schOpenRecordId\\\":\\\"218430187829080064\\\",\\\"schemeAuthorizationType\\\":\\\"FIXED_TIME\\\",\\\"subjectLifeCycle\\\":\\\"CURRENTLY_VALID\\\",\\\"totalNum\\\":0},\\\"EVA_THEME\\\":{\\\"applexName\\\":\\\"设计工具2.0\\\",\\\"authorizationId\\\":\\\"369963861191585792\\\",\\\"authorizationKeyTypeCode\\\":\\\"EVA_THEME\\\",\\\"authorizationName\\\":\\\"设计工具2.0\\\",\\\"authorizationNum\\\":\\\"10000\\\",\\\"authorizationObjectId\\\":\\\"218430187715969024\\\",\\\"authorizationSchemeId\\\":\\\"364404654094036992\\\",\\\"authorizationSpaceId\\\":\\\"81705860010741760\\\",\\\"authorizationUnit\\\":\\\"COVER\\\",\\\"deployTypeCode\\\":\\\"SAAS\\\",\\\"isDeploymentEnabled\\\":\\\"TRUE\\\",\\\"isMainAuthorization\\\":\\\"FALSE\\\",\\\"operateTime\\\":1719755058000,\\\"operationInductionId\\\":\\\"128894511698157568\\\",\\\"pageNum\\\":0,\\\"pageSize\\\":0,\\\"schOpenRecordCode\\\":\\\"365913486196617217\\\",\\\"schOpenRecordId\\\":\\\"365913486196617216\\\",\\\"schemeAuthorizationType\\\":\\\"QUANTITY\\\",\\\"subjectLifeCycle\\\":\\\"CURRENTLY_VALID\\\",\\\"totalNum\\\":0},\\\"TENANT_SPACE\\\":{\\\"applObjType\\\":\\\"PLATFORM\\\",\\\"applexName\\\":\\\"江苏新数质\\\",\\\"authorizationId\\\":\\\"369963861271277568\\\",\\\"authorizationKeyTypeCode\\\":\\\"TENANT_SPACE\\\",\\\"authorizationName\\\":\\\"江苏新数质\\\",\\\"authorizationNum\\\":\\\"10000\\\",\\\"authorizationObjectId\\\":\\\"81705860010741760\\\",\\\"authorizationSchemeId\\\":\\\"364182676397502464\\\",\\\"authorizationSpaceId\\\":\\\"81705860010741760\\\",\\\"authorizationUnit\\\":\\\"COVER\\\",\\\"deployTypeCode\\\":\\\"SAAS\\\",\\\"isDeploymentEnabled\\\":\\\"TRUE\\\",\\\"isMainAuthorization\\\":\\\"TRUE\\\",\\\"operateTime\\\":1719755058000,\\\"operationInductionId\\\":\\\"128894511698157568\\\",\\\"pageNum\\\":0,\\\"pageSize\\\":0,\\\"schOpenRecordCode\\\":\\\"365902607375806465\\\",\\\"schOpenRecordId\\\":\\\"365902607375806464\\\",\\\"schemeAuthorizationType\\\":\\\"QUANTITY\\\",\\\"spaceShortName\\\":\\\"江苏新数质\\\",\\\"subjectLifeCycle\\\":\\\"CURRENTLY_VALID\\\",\\\"totalNum\\\":0},\\\"WORK_KPI\\\":{\\\"applObjType\\\":\\\"EVA_THEME\\\",\\\"applexName\\\":\\\"工作绩效（评价主题）\\\",\\\"authorizationId\\\":\\\"2241875641510297607\\\",\\\"authorizationKeyTypeCode\\\":\\\"WORK_KPI\\\",\\\"authorizationName\\\":\\\"工作绩效（评价主题）\\\",\\\"authorizationNum\\\":\\\"1\\\",\\\"authorizationObjectId\\\":\\\"217765674712842240\\\",\\\"authorizationSchemeId\\\":\\\"215428055324569600\\\",\\\"authorizationSpaceId\\\":\\\"81705860010741760\\\",\\\"authorizationUnit\\\":\\\"COVER\\\",\\\"deployTypeCode\\\":\\\"SAAS\\\",\\\"isDeploymentEnabled\\\":\\\"TRUE\\\",\\\"isMainAuthorization\\\":\\\"TRUE\\\",\\\"operateTime\\\":1684999280000,\\\"operationInductionId\\\":\\\"127121849724444672\\\",\\\"pageNum\\\":0,\\\"pageSize\\\":0,\\\"schOpenRecordCode\\\":\\\"217765675132137473\\\",\\\"schOpenRecordId\\\":\\\"217765675132137472\\\",\\\"schemeAuthorizationType\\\":\\\"QUANTITY\\\",\\\"subjectLifeCycle\\\":\\\"CURRENTLY_VALID\\\",\\\"totalNum\\\":0},\\\"MID_DEPT_KPI\\\":{\\\"applexName\\\":\\\"部门绩效主题\\\",\\\"authorizationId\\\":\\\"369963860986064896\\\",\\\"authorizationKeyTypeCode\\\":\\\"MID_DEPT_KPI\\\",\\\"authorizationName\\\":\\\"部门绩效主题\\\",\\\"authorizationNum\\\":\\\"1\\\",\\\"authorizationObjectId\\\":\\\"369767774627053568\\\",\\\"authorizationSchemeId\\\":\\\"369264827270836224\\\",\\\"authorizationSpaceId\\\":\\\"81705860010741760\\\",\\\"authorizationUnit\\\":\\\"COVER\\\",\\\"deployTypeCode\\\":\\\"SAAS\\\",\\\"isDeploymentEnabled\\\":\\\"TRUE\\\",\\\"isMainAuthorization\\\":\\\"TRUE\\\",\\\"operateTime\\\":1719761315000,\\\"operationInductionId\\\":\\\"128894511698157568\\\",\\\"pageNum\\\":0,\\\"pageSize\\\":0,\\\"schOpenRecordCode\\\":\\\"369767895649366017\\\",\\\"schOpenRecordId\\\":\\\"369767895649366016\\\",\\\"schemeAuthorizationType\\\":\\\"QUANTITY\\\",\\\"subjectLifeCycle\\\":\\\"CURRENTLY_VALID\\\",\\\"totalNum\\\":0},\\\"DOUBLE_HEIGHT_PLAN\\\":{\\\"applObjType\\\":\\\"EVA_THEME\\\",\\\"applexName\\\":\\\"双高规划（评价主题）\\\",\\\"authorizationId\\\":\\\"2241875641510297605\\\",\\\"authorizationKeyTypeCode\\\":\\\"DOUBLE_HEIGHT_PLAN\\\",\\\"authorizationName\\\":\\\"双高规划（评价主题）\\\",\\\"authorizationNum\\\":\\\"5\\\",\\\"authorizationObjectId\\\":\\\"168358596865179648\\\",\\\"authorizationSchemeId\\\":\\\"215428055324569600\\\",\\\"authorizationSpaceId\\\":\\\"81705860010741760\\\",\\\"authorizationStartTime\\\":1567267202000,\\\"authorizationUnit\\\":\\\"YEAR\\\",\\\"deployTypeCode\\\":\\\"SAAS\\\",\\\"isDeploymentEnabled\\\":\\\"TRUE\\\",\\\"isMainAuthorization\\\":\\\"TRUE\\\",\\\"operateTime\\\":1684999280000,\\\"operationInductionId\\\":\\\"127121849724444672\\\",\\\"pageNum\\\":0,\\\"pageSize\\\":0,\\\"schOpenRecordCode\\\":\\\"141640708653461505\\\",\\\"schOpenRecordId\\\":\\\"141640708653461504\\\",\\\"schemeAuthorizationType\\\":\\\"CYCLE_TIME\\\",\\\"subjectLifeCycle\\\":\\\"CURRENTLY_VALID\\\",\\\"totalNum\\\":0}}}\"";
        if(useFlag!=null && useFlag.equals("use")){
//            str = douliwan.loadInfo();
            System.out.println("douliwan:"+str);
        }

        CommonFunctionHelper.setSecStr(str);
        CommonFunctionHelper.setFilePath(filePath);
        CommonFunctionHelper.setRedisUtil(redisUtil);
        CommonFunctionHelper.getConfigInfo().put("security.db.address",dbAddress);
        CommonFunctionHelper.getConfigInfo().put("security.db.account",dbAccount);
        CommonFunctionHelper.getConfigInfo().put("security.db.password",dbPassword);

    }
}
